package com.example.backadmindemo.controller;

import com.example.backadmindemo.pojo.Label;
import com.example.backadmindemo.service.LabelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@CrossOrigin
public class LabelController {
    @Autowired
    private LabelService labelService;

    @GetMapping("/select/{currentPage}/{pageSize}")
    public List<Label> select(@PathVariable("currentPage") int currentPage, @PathVariable("pageSize") int pageSize) {
        return labelService.select(currentPage, pageSize);
    }

    @GetMapping("/selectGoal/{currentPage}/{pageSize}")
    public List<Label> selectGoal(@PathVariable("currentPage") int currentPage, @PathVariable("pageSize") int pageSize) {
        return labelService.selectGoal(currentPage, pageSize);
    }

    @GetMapping("/getSelect")
    public Integer getSelect() {
        return labelService.getSelect();
    }

    @GetMapping("/getSelectGoal")
    public Integer getSelectGoal() {
        return labelService.getSelectGoal();
    }

    @GetMapping("/setGoal/{id}")
    public void setGoal(@PathVariable("id") String id) {
        int realID  = Integer.parseInt(id);
        labelService.setGoal(realID);
    }

    @GetMapping("/cancelGoal/{id}")
    public void cancelGoal(@PathVariable("id") String id) {
        int realID  = Integer.parseInt(id);
        labelService.cancelGoal(realID);
    }
}
